from redis import Redis


class RedisCon:
    def __init__(self):
        self.conn = redis.Redis(host='localhost', port='6379', db=1)

    # 存
    def insert_set(self, key, value):
        self.conn.sadd(key, value)

    # 取
    def find_set(self, key):
        value = self.conn.smembers(key)

        if value:
            value = str(value, encoding='utf8')
        return value

    # 删除
    def str_del(self, key):
        return self.conn.delete(key)


r = RedisCon()
#  测试是否成功


# r.str_set('name', '123', 30)
# print(r.str_get('name'))
